import http from "@/utils/http";
/**
 * 登录
 * @param {*} user 
 * @param {*} passwd 
 * @returns 
 */
export function login(baseUrl,user, passwd) {
  const params = {
    user,
    passwd,
  }
  return http.post(`${baseUrl?baseUrl:""}/api/um/checkUserPassword`, 
  params
  );
}
/**
 * 登出
 * @returns
 */
export function loginOut(baseUrl,name) {
  return http.get(`${baseUrl?baseUrl:""}/api/um/loginOut/${name}`);
}
/**
 * 添加用户
 * @param {} params 
 * @returns 
 */
export function addUser(baseUrl,params) {
  return http.post(`${baseUrl?baseUrl:""}/api/um/addUser`, params);
}
/**
 * 更新用户
 * @param {*} id 
 * @param {*} params 
 * @returns 
 */
export function updateUser(baseUrl,id, params) {
  return http.post(`${baseUrl?baseUrl:""}/api/um/updateUser/${id}`, params);
}
/**
 * 删除用户
 * @param {*} id 
 * @returns 
 */
export function delUser(baseUrl,id) {
  return http.get(`${baseUrl?baseUrl:""}/api/um/delUser/${id}`);
}
/**
 * 批量删除用户
 * @param {*} id 
 * @returns 
 */
 export function bulkDelUser(baseUrl,users) {
  return http.post(`${baseUrl?baseUrl:""}/api/um/bulkDelUser`,users);
}
/**
 * 根据用户user
 * @param {*} user
 * @returns
 */
export function getUser(baseUrl,user) {
  return http.get(`${baseUrl?baseUrl:""}/api/um/getUserByAcc/${user}`);
}
/**
 * 根据level查询user
 * @param {*} user
 * @returns
 */
export function getAdminByLevel(baseUrl,level) {
  return http.get(`${baseUrl?baseUrl:""}/api/um/getAdminByLevel/${level}`);
}
/**
 * 获取用户列表
 * @param {*} params 
 * @returns 
 */
export function getUserList(baseUrl,params) {
  return http.get(
    `${baseUrl?baseUrl:""}/api/um/getUserList?page=${params.current}&limit=${params.pageSize}&name=${
      params.name ? params.name : ""
    }&level=${params.level}&searchLevel=${params.searchLevel}`
  );
}
